<?php

namespace App\Http\Controllers\Api;

use App\Models\Shop\Category;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\Ad\Advert;
use App\Models\Shop\Product;

class HomeController extends Controller
{

    /**
     * @return array
     * 首页
     */
    public function index()
    {
        //首页焦点图
        $sliders = Advert::where('category_id', 1)->orderBy('sort_order')->get();
        //首页banner图
        $banners = Advert::where('category_id', 2)->limit(3)->get();
        //商品列表
        $products = Product::where('is_onsale', 1)->limit(3)->get();

        return response()->json(compact('sliders', 'banners', 'products'));
    }

}
